<?php /* Smarty version Smarty-3.0.8, created on 2014-11-03 19:12:44
         compiled from "tpl/js/controller/setting-team-list.js" */ ?>
<?php /*%%SmartyHeaderCode:176825457632c7d1472-90536684%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'e4ee4c3496cdcb4f47c2096a8f26c6916cdc3508' => 
    array (
      0 => 'tpl/js/controller/setting-team-list.js',
      1 => 1410832240,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '176825457632c7d1472-90536684',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
      //团队设置
      App.controller('setting-team-list', function (page) {        
        $(page).on("appReady",function(){
          $.post(url("team","team_list"),{name:kget("username")},function(data){
            for(var i=0;i<data['own'].length;i++){             
              var Div = $("<div>").addClass("ptime-team");
              var inDiv = $("<div>").addClass("ptime-team-name active").html(data['own'][i].team_name);
              if(i==0){
                var inUl = $("<ul>").addClass("app-list").css({"display":"block"});
              }else{
                var inUl = $("<ul>").addClass("app-list").css({"display":"none"});
              }
              
              var inLi1 = $("<li>").addClass("app-button").data("contact",data['own'][i]).html("添加/删除成员");
              var inLi2 = $("<li>").addClass("app-button").html("记账");
              var inLi3 = $("<li>").addClass("app-button").data("delete_team",data['own'][i]).html("删除");
              inUl.append(inLi1).append(inLi2).append(inLi3);
              Div.append(inDiv).append(inUl);
              $(page).find(".ptime-own-team").append(Div);

              inLi1.on("tap",function(){
                var contact=$(this).data("contact");
                App.load("setting-team-content",contact);                
              });

              inLi3.on("tap",function(){
                var delete_team = $(this).data("delete_team");
                var li3_this = $(this);
                App.dialog({
                  title: '您确定要删除改团队吗？',okButton: '确定',cancelButton: '取消'
                }, function (ok,cancel) {
                  if (ok) {
                    $.post("<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'team','a'=>'delete_team'),$_smarty_tpl);?>
",{team_id:delete_team.team_id},function(data){
                      if(typeof(data.errmsg) != "undefined"){
                        alert(data.errmsg);
                      }else{
                        li3_this.parents("div.ptime-team").remove();
                        alert("删除成功！");                    
                      }
                    },"json");
                  }
                });
              });
              inDiv.on("tap",function(){           
                $(this).next("ul").slideToggle();
              });
              
            }
            for(var i=0;i<data['join'].length;i++){             
              var join_Div = $("<div>").addClass("ptime-team");
              var join_inDiv = $("<div>").addClass("ptime-team-name").html(data['join'][i].team_name);
              var join_inUl = $("<ul>").addClass("app-list").css({"display":"none"});
              var inLi4 = $("<li>").addClass("app-button").html("记账");
              var inLi5 = $("<li>").addClass("app-button").data("delete_team",data['join'][i]).html("删除");
              join_inUl.append(inLi4).append(inLi5);
              join_Div.append(join_inDiv).append(join_inUl);
              $(page).find(".ptime-join-team").append(join_Div);

              inLi5.on("tap",function(){
                var delete_team = $(this).data("delete_team");
                var li5_this = $(this);
                App.dialog({
                  title: '您确定要退出该团队吗？',okButton: '确定',cancelButton: '取消'
                }, function (ok,cancel) {
                  if (ok) {
                    $.post(url("team","delete_team"),{team_id:delete_team.team_id},function(data){
                      if(typeof(data.errmsg) != "undefined"){
                        alert(data.errmsg);
                      }else{
                        li5_this.parents("div.ptime-team").remove();
                        alert("退出成功！");                    
                      }
                    },"json");
                  }
                });
              });
              join_inDiv.on("tap",function(){           
                $(this).next("ul").slideToggle();
              });
              
            }
          },"json");
        });
      });